/*
 * @Author: cooper
 * @Date: 2025-03-30 21:35:19
 * @Wechat: cmd_develop
 * @Description:
 */
#ifndef BSP_FOOD
#define BSP_FOOD

#include "common.h"

extern QueueHandle_t food_work_queue;

void FOOD_UART_INIT(void);
void FOOD_TASK(void);
void FOOD_UART_DMA_TX(u16 size);
void food_cmd_queue_send(u8 code[3]);

#define food_DATA_SIZE 30

typedef struct
{
    u8 rx_data[food_DATA_SIZE]; /*接收数据缓冲区*/
    u16 rx_total;               /*接收数据大小*/
    u8 tx_data[food_DATA_SIZE]; /*发送数据缓冲区*/
    u16 tx_total;               /*发送总数据大小*/
} food_buffer;

extern food_buffer food_Buffer;

#define RX_food(x) food_Buffer.rx_data[x]
#define RX_food_TOTAL food_Buffer.rx_total
#define TX_food(x) food_Buffer.tx_data[x]
#define TX_food_TOTAL food_Buffer.tx_total

#define RX_food_BufClear()                      \
    do                                          \
    {                                           \
        for (u16 i = 0; i < RX_food_TOTAL; i++) \
        {                                       \
            RX_food(i) = 0;                     \
        }                                       \
        RX_food_TOTAL = 0;                      \
    } while (0)
#define TX_food_BufClear()                      \
    do                                          \
    {                                           \
        for (u16 i = 0; i < TX_food_TOTAL; i++) \
        {                                       \
            TX_food(i) = 0;                     \
        }                                       \
        TX_food_TOTAL = 0;                      \
    } while (0)

#endif
